package src;

import java.util.HashSet;
import java.util.Stack;

import org.junit.Test;

public class MyTest {
    public int canBeTypedWords(String text, String brokenLetters) {
        HashSet<Character> hashSet=new HashSet<Character>();
        int count=0;
        for(char c:brokenLetters.toCharArray()){
            hashSet.add(c);
        }
        for(int i=0;i<text.length();i++){
            if(hashSet.contains(text.charAt(i))){
                count++;
                while(i+1<text.length()&&text.charAt(i+1)!=' '){
                    i++;
                }
            }
        }
        return count;
    }

    public int addRungs(int[] rungs, int dist) {
        int ans=0;
        int maxStep=dist;
        for(int i:rungs){
            while(maxStep<i){
                maxStep+=dist;
                ans++;
            }
            maxStep+=dist;
        }
        return ans;
    }


    private long ans=0;
    public long maxPoints(int[][] points) {
        traceBack(points, 0, -1, 0);
        return ans;
    }
    private void traceBack(int[][] points,int r,int c,long currPoints){
        if(r==points[0].length){
            ans=Math.max(ans, currPoints);
            return;
        }
        for(int i=0;i<points[r].length;i++){
            traceBack(points, r+1, i, currPoints+points[r][i]-((c==-1)?0:Math.abs(i-c)));
        }
    }
    @Test
    public void test(){
        int[][] points={{1,5},{2,3},{4,2}};
        System.out.println(maxPoints(points));
    }
}
